/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.belfalas.simy86;

/**
 *
 * @author belfalas
 */
public class ConditionCodes {
    
    public static byte CC = 0;
    
    public static void setOF (boolean bool){
        int i = bool ? 1 : 0;
        CC = (byte) ((CC & ~(1)) | (i));
    }
    
    public static void setZF (boolean bool){
        int i = bool ? 1 : 0;
        CC = (byte) ((CC & ~(1<<1)) | (i << 1));
    }
    
    public static void setSF (boolean bool){
        int i = bool ? 1 : 0;
        CC = (byte) ((CC & ~(1<<2)) | (i << 2));
    }
    
    public static void setPID (boolean bool){
        int i = bool ? 1 : 0;
        CC = (byte) ((CC & ~(1<<3)) | (i << 3));
    }
    
    public static boolean get0F (){
        int bool = CC & (1);
        switch (bool){
            case 1 : return true;
            case 0 : return false;
        }
        return false;
    }
    
    public static boolean getZF (){
        int bool = (CC >> 1) & 1;
        switch (bool){
            case 1 : return true;
            case 0 : return false;
        }
        return false;
    }
    
    public static boolean getSF (){    
        int bool = (CC >> 2) & 1;
        switch (bool){
            case 1 : return true;
            case 0 : return false;
        }
        return false;
    }
    
    public static boolean getPID (){
        int bool = (CC >> 3) & 1;
        switch (bool){
            case 1 : return true;
            case 0 : return false;
        }
        return false;
    }
}
